<template>
    <p>Home</p>
    <h2>路由跳转</h2>
    <button @click="pushStr">push-字符串-跳转</button>
    <button @click="pushPath">push-路径-跳转</button>
    <button @click="pushName">push-名字-跳转</button>
    <h2>传递参数</h2>
    <button @click="pushAname">push-name</button>
</template>

<script setup>

//引入userouter
import {useRouter} from 'vue-router'

//获取路由的实例化对象
const router = useRouter()

const pushStr=()=>{
    router.push('/about')
}
const pushPath=()=>{
    router.push({path:'/about'})
}
const pushName=()=>{
    router.push({name:'about'})
}
const pushAname =()=>{
  router.push({path:'/about',query:{name:'tom'}})
}
</script>